﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Api.Model
{
    public class BaseModel
    {
        //我觉得应该分清楚一下，新增修改和从数据库中读取的时候分别是怎么调用get和set方法的

        private DateTime updateDate;
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }
        public decimal Sort { get; set; } = Convert.ToDecimal(DateTime.Now.ToString("yyyyMMddHHmmss"));
        public DateTime? CreateDate { get; set; }
        public DateTime UpdateDate
        {
            get { return updateDate; }
            set
            {
                updateDate = value;
                if (updateDate == null)
                {
                    updateDate = DateTime.Now;
                }
            }
        }


    }
}
